#!/usr/bin/python
# -*- coding: utf-8 -*-  

import sys
import constante as cons
import ConfigParser

if __name__ == "__main__":
	cons.ROM = sys.argv[1]
	cfg = ConfigParser.SafeConfigParser()
	cfg.read('chip8rc')
	
	cons.PIXEL_SIZE = cfg.getint('CHIP8', 'pixel_size')
	cons.RAM_SIZE = cfg.getint('CHIP8', 'ram_size')
	cons.FREQUENCY = cfg.getint('CHIP8', 'cpu_frequency')
	cons.FPS = cfg.getint('CHIP8', 'screen_frequency')
	engine = cfg.get('CHIP8', 'engine')
	
	if engine in ("text", "curses", "ncurse"):
		import ncurses_engine
		import curses
		curses.wrapper(ncurses_engine.CursesEngine)
		curses.endwin()
	elif engine in ("pygame", "graphic", "sdl"):
		import pygame_engine
		pygame_engine.PygameEngine()
	#sys.exit()